package com.eshop.config;

import org.springframework.context.annotation.Bean;
import com.eshop.api.LicenseCheckInterceptor;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class ResourcesConfig implements WebMvcConfigurer
{
    public void addInterceptors(final InterceptorRegistry registry) {
        registry.addInterceptor(this.getLicenseCheckInterceptor()).excludePathPatterns(new String[] { "/auth/code" }).excludePathPatterns(new String[] { "/auth/login" }).excludePathPatterns(new String[] { "/api/sendSMS" }).excludePathPatterns(new String[] { "/logout" }).excludePathPatterns(new String[] { "/api/install" }).excludePathPatterns(new String[] { "/api/license/apply" }).excludePathPatterns(new String[] { "/api/menus/build" }).excludePathPatterns(new String[] { "/api/getPCCanvas" }).excludePathPatterns(new String[] { "/file/**" }).excludePathPatterns(new String[] { "/index.html" }).excludePathPatterns(new String[] { "/error" });
    }
    
    @Bean
    public HandlerInterceptor getLicenseCheckInterceptor() {
        return (HandlerInterceptor)new LicenseCheckInterceptor();
    }
}
